<?xml version="1.0" encoding="utf-8"?>
<%@ page contentType="text/xml;charset=utf-8"%>
<%@ page import="java.io.InputStream"%>
<%@ page import="java.io.OutputStream"%>
<%@ page import="com.tomato.dao.*"%>
<%@ page import="com.tomato.bean.*"%>
<%@ page import="com.tomato.servlet.*"%>
<%@ page import="java.util.List"%>
<%@ page import="javax.jdo.PersistenceManager"%>
<%@ page import="javax.jdo.Query"%>
<%@ page import="com.google.appengine.api.datastore.Blob"%>
<%@ page import="org.apache.commons.lang.*"%>

<data> <%
 	//String condition = request.getParameter("condition");
 	//String condition = "count";
 	response.setContentType("text/xml; charset=utf-8");
 	request.setCharacterEncoding("utf-8");
 	String condition = "date";
 	PersistenceManager pm = PMF.get().getPersistenceManager();
 	Query query = pm.newQuery(Photo.class);
 	if (condition.equals("count")) {
 		query.setOrdering("count desc");
 	} else if (condition.equals("date")) {
 		query.setOrdering("date desc");
 	}
 	List<Photo> photo = (List<Photo>) query.execute();

 	//List<Photo> photo = (List<Photo>)request.getAttribute("photo");
 	for (Photo photos : photo) {
 		byte[] b = photos.getEbook().getBytes();
 		String str = StringEscapeUtils.escapeXml(new String(b,"utf-8"));
 %> 
<lists> 
	<id><%=photos.getId()%></id> 
	<genre><%=photos.getGenre()%></genre>
	<title><%=photos.getTitle()%></title> 
	<author><%=photos.getAuthor()%></author>
	<description><%=photos.getDescription()%></description> 
	<ebook><%=str%></ebook>
	<count><%=photos.getCount()%></count> 
	<date><%=photos.getDate()%></date>
</lists> <%
 	}
 %> </data>
